import request from "@/api/request";
import mockR from "@/api/mockRequest";

// 三级联动接口
export const reqCategoryList = () => {
  return request({
    url: "/product/getBaseCategoryList",
    method: "get",
  });
};

// 轮播图
export const reqBanner = () => {
  return mockR({
    url: "/banner",
    method: "get",
  });
};

// floor数据
export const reqFloor = () => {
  return mockR({
    url: "/floor",
    method: "get",
  });
};

//获取搜索模块数据
export const reqGoodsList = (data) => {
  return request({
    url: "/list",
    method: "post",
    data,
  });
};

//获取商品详情信息
export const reqGoodsDetail = (skulid) => {
  return request({
    url: `/item/${skulid}`,
    method: "get",
  });
};
//添加购物车数量
export const reqShoppingNum = (skuid, skuNum) => {
  return request({
    url: `/cart/addToCart/${skuid}/${skuNum}`,
    method: "post",
  });
};

//获取购物车列表
export const reqShopCartList = () => {
  return request({
    url: "/cart/cartList",
    method: "get",
  });
};

//删除购物车商品
export const reqDeleteCart = (skuId) => {
  return request({
    url: `/cart/deleteCart/${skuId}`,
    method: "delete",
  });
};

//切换商品选中状态
export const reqTabChected = (skuId, isChecked) => {
  return request({
    url: `/cart/checkCart/${skuId}/${isChecked}`,
    method: "get",
  });
};

//获取手机验证码
export const reqGetPhoneCode = (phone) => {
  return request({
    url: `user/passport/sendCode/${phone}`,
    method: "get",
  });
};

//注册
export const reqRegister = (data) => {
  return request({
    url: "/user/passport/register",
    method: "post",
    data,
  });
};

//登录
export const reqLogin = (data) => {
  return request({
    url: "/user/passport/login",
    method: "post",
    data,
  });
};

//获取用户信息
export const reqGetUserInfo = () => {
  return request({
    url: "/user/passport/auth/getUserInfo",
    method: "get",
  });
};

//退出登录
export const reqLogout = () => {
  return request({
    url: "/user/passport/logout",
    method: "get",
  });
};

//获取用户地址信息
export const reqGetUserAddress = () => {
  return request({
    url: "/user/userAddress/auth/findUserAddressList",
    method: "get",
  });
};

//获取订单交易页信息
export const reqGetOrder = () => {
  return request({
    url: "/order/auth/trade",
    method: "get",
  });
};

//提交订单
export const reqSubmitOrder = (data, tradeNo) => {
  return request({
    url: `/order/auth/submitOrder?tradeNo=${tradeNo}`,
    method: "post",
    data,
  });
};

//获取订单支付信息
export const reqPayOrder = (orderId) => {
  return request({
    url: `/payment/weixin/createNative/${orderId}`,
    method: "get",
  });
};

//获取订单支付信息
export const reqQueryPayStatus = (orderId) => {
  return request({
    url: `/payment/weixin/queryPayStatus/${orderId}`,
    method: "get",
  });
};

//获取我的订单列表
export const reqMyOrderList = (page,limit) => {
  return request({
    url: `/order/auth/${page}/${limit}`,
    method: "get",
  });
};
